package com.ash.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2020/12/26 12:21
 * @file : test06.${PACKAGE_NAME}.${NAME}.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
@WebFilter("/*")
public class CodingFilter implements Filter {
    @Override
    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        System.out.println("来到codingFilter");
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("html/text;charset=UTF-8");
        chain.doFilter(req, resp);
    }

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

}
